package com.xayy.ds.controller;

import cn.kawins.base.result.ResultBody;
import com.xtck.ha.common.core.constant.HttpStatus;
import com.xtck.ha.common.core.utils.poi.ExcelUtil;
import com.xtck.ha.common.core.web.controller.BaseController;
import com.xtck.ha.common.core.web.domain.AjaxResult;
import com.xtck.ha.common.core.web.page.TableDataInfo;
import com.xayy.ds.model.DsAssessTaskInfo;
import com.xayy.ds.service.DsAssessTaskInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 模型列表 controller
 *
 * @ClassName: TestAssessTaskInfoController
 * @Description: 外部访问接口
 * @author zhoutanxin
 * @date 2025-06-30
 */
@Api(tags = "评估任务表管理")
@RestController
@RequestMapping("/api/v1.0/dsAssessTaskInfo")
public class DsAssessTaskInfoController extends BaseController {

    @Resource(name="dsAssessTaskInfoService")
    private DsAssessTaskInfoService dsAssessTaskInfoService;


    @ApiOperation("分页查询评估任务表列表")
    @GetMapping("/page")
    public AjaxResult page(DsAssessTaskInfo dsAssessTaskInfo)
    {
        startPage();
        List<DsAssessTaskInfo> list = dsAssessTaskInfoService.selectTList(dsAssessTaskInfo);
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(HttpStatus.SUCCESS);
        rspData.setList(list);
        rspData.setMsg("查询成功");
        rspData.setTotal(dsAssessTaskInfoService.count(dsAssessTaskInfo));
        return AjaxResult.success(rspData);
    }

    @ApiOperation("列表查询评估任务表")
    @GetMapping("/list")
    public List<DsAssessTaskInfo> list(DsAssessTaskInfo dsAssessTaskInfo)
    {
        List<DsAssessTaskInfo> list = dsAssessTaskInfoService.selectTList(dsAssessTaskInfo);
        return list;
    }

    @ApiOperation("导出评估任务表列表")
    @PostMapping("/export")
    public void export(HttpServletResponse response, DsAssessTaskInfo dsAssessTaskInfo)
    {
        List<DsAssessTaskInfo> list = dsAssessTaskInfoService.selectTList(dsAssessTaskInfo);
        ExcelUtil<DsAssessTaskInfo> util = new ExcelUtil<>(DsAssessTaskInfo.class);
        util.exportExcel(response, list, "样例数据");
    }

    @ApiOperation("获取$评估任务表详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dsAssessTaskInfoService.selectTById(id));
    }

    @ApiOperation("新增$评估任务表")
    @PostMapping
    public AjaxResult add(@RequestBody DsAssessTaskInfo dsAssessTaskInfo)
    {
        return toAjax(dsAssessTaskInfoService.insertT(dsAssessTaskInfo));
    }

    @ApiOperation("修改评估任务表")
    @PutMapping
    public AjaxResult update(@RequestBody DsAssessTaskInfo dsAssessTaskInfo)
    {
        int i = dsAssessTaskInfoService.updateT(dsAssessTaskInfo);
        return toAjax(i);
    }

    @ApiOperation("删除评估任务表")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dsAssessTaskInfoService.deleteTByIds(ids));
    }


    @GetMapping("/toggleStartPause/{id}")
    @ApiOperation(value = "启动/暂停任务")
    public ResultBody toggleStartPause(@PathVariable("id") String idstr){
        Long id =  Long.parseLong(idstr);
        dsAssessTaskInfoService.toggleStartPause(id);
        return ResultBody.success();
    }



}
